﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for ICPUser
/// </summary>
public static class ICPUser
{
    public static String Role
    {
        get { return "OK"; } // DEV ONLY
    }

    public static String ID
    {
        get { return System.Web.HttpContext.Current.User.Identity.Name.Split('|')[1]; } 
    }

    public static String Name
    {
        get { return System.Web.HttpContext.Current.User.Identity.Name.Split('|')[3]; }
    }

    public static String Initial
    {
        get { return System.Web.HttpContext.Current.User.Identity.Name.Split('|')[2]; }
    }

    public static int RoleId
    {
        get
        {
            int iRet = 0;
            String[] sxSplitted = System.Web.HttpContext.Current.User.Identity.Name.Split('|');
            iRet = int.Parse(sxSplitted[4]); 
            return iRet;
        }
    }

    public static ICPUserRole UserRole
    {
        get
        {
            return (ICPUserRole)RoleId;
        }
    }

    public static bool IsAdmin
    {
        get
        {
            return UserRole == ICPUserRole.Administrator;
        }
    }
    public static bool IsAdminForum
    {
        get
        {
            return (UserRole == ICPUserRole.CARAdminForum) || (UserRole == ICPUserRole.AdminForum);
        }
    }
    public static bool IsHelpDesk
    {
        get
        {
            return (UserRole == ICPUserRole.CARHelpDesk) || (UserRole == ICPUserRole.HelpDesk);
        }
    }
    public static bool IsSSE
    {
        get
        {
            return (UserRole == ICPUserRole.SSE);
        }
    }
}

